1. Field of the Invention
The present invention relates to computer graphics, and more specifically relates to pixel sample manipulation.
2. Description of the Related Art
In a computer graphics display application, an image is generated by a display system and displayed on a screen. The image is composed by an array of individual picture-cells (“pixels”). Pixels are the dots of color that define the image. Each of the pixels is defined by characteristics such as color and intensity. Traditionally, pixels are organized into a two-dimensional array or grid defined by raster lines. Each line is drawn by scan displaying the individual pixels along the line.
In practice, rather than defining the characteristics of each pixel, display systems define an image from a collection of primitive graphic shapes such as polygons. The polygons are numerically represented in terms of size, color, location and other characteristics, and the most common polygons used in rendering graphic images are triangles. To accomplish an image, the polygon representations are processed by an image generator producing pixel data signals through a process called polygon rendering. In effect, polygon rendering involves sampling a polygon to calculate how the polygon influences the pixels.
Display systems typically generate each pixel data signal by sampling several locations within the pixel of the polygon. This sampling technique is used to reduce undesirable visual artifacts in the displayed image. These visual artifacts, commonly referred to as aliasing, often appear as jagged lines at the polygon boundaries.
Some reduction of artifacts can be achieved with “polygon smoothing.” Polygon smoothing is achieved by computing a coverage value for each pixel a polygon touches. The coverage value is proportional to the amount of the pixel covered by the polygon. The coverage value is used to modify alpha, which is used to blend to color of the polygon with contents of the frame buffer. In this technique, each fragment generated by rendering a triangle or other primitive is sampled at a higher rate. The total number of samples lit by the fragment modulates the intensity of the color for the fragment. However, this technique requires that the triangles in the scene be sorted by depth. The sorting is computational intensive.
The visual artifacts can also be reduced by a technique known as multisampling. Multisampling does not require sorting. Each pixel will have all its samples stored in the frame buffer. The standard Z buffering algorithm is applied to each sample.
Multisampling increases the sample rate for a given display resolution. The sample rate is arbitrary, but is usually 2, 4, 8 or 16 samples per pixel. The higher the sample rate, the less visual artifacts appear in the final image.
Cables are an example of objects that produce visual artifacts. If a cable is in the distance, then its width will be less than one pixel on the display. Without multisampling, the cable will appear as a dotted line, with each pixel that the cable passes through appearing as a dot. As the viewpoint of the cable changes, the dots will appear to move like raindrops.
With multisampling, the cable will light a small portion of every pixel it passes through. The intensity of each pixel will be proportional to the size of the cable. This reduces or eliminates the dotted line effect.
Multisampling is also useful to render transparent objects. Many scenes contain transparent objects such as windows. These objects affect the color of a pixel, but allow objects behind them to be visible. Opaque objects in front of a transparent object occlude the transparent object. If pixels are sampled at 16 samples per pixel, then a transparent object that transmits {fraction (15/16)}th of all the light passing through it can be rendered by discarding 15 of the 16 samples taken while rendering it. In other words, a transparent object transmitting {fraction (15/16)}th of all the light passing through it can be rendered by discarding 15 of the 16 samples. The transparent object is rendered by changing color for only one sample. However, picking the same sample in every pixel to keep may introduce visual artifacts that multisampling is supposed to remove.
Therefore, it is desirous to have a system and method for selecting samples of a pixel to prevent introduction of visual artifacts when multisampling is used to improve quality of rendered images. Accordingly, it is to the provision of such a system and method that the primary invention is primarily directed.